<template>
  <div class="about">
    <h1>{{msg}}</h1>
    <h1>{{propsdata}}</h1>
    <button @click="increment">ClickTest</button>
  </div>
</template>

<script type="text/javascript">
	import * as mutation_types from '@/store/modules/mutation_types';
	import axios from 'axios'
	export default {
		data(){
			return {
				msg:'nothing'
			}
		},
		props:['propsdata'],
		created(){
			let data = '蔡文俊';
			this.submitTovuex(data);
		},
		methods:{
			submitTovuex:function(data){
				this.$store.commit(mutation_types.SET_USER_INFO,data);
				this.$store.dispatch(mutation_types.GET_USER_INFO,data);
				return true;
			},
			increment:function(){
				return new Promise((resolve,reject) => {
					axios.get('/mockdata')
					.then(res=>{
                        console.log(res);
						resolve(res);
					})
					.catch(err=>{
						reject(err);
					})
				})
			},
			watchMethod:function(val){
				console.log(val);
			}
		},
		watch:{
			msg:function(newval,oldval){
				this.watchMethod(newval);
			}
		}
	}
</script>
